package com.xbongbong.pro.enums.permission.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.Objects;

/**
 * @Author shian
 * @create 2019-07-06 17:37
 */
@Getter
public enum ViewProPermissionAliasEnum {
    /**
     * tb_pro_promission对应的alias字段
     */
    CUSTOMER_COMMUNICATE_VIEW(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), "customerCommunicateView", ProPermissionAliasEnum.CUSTOMER_COMMUNICATE_VIEW.getI18nMemo()),

    OPPORTUNITY_VIEW(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode(), "opportunityView", ProPermissionAliasEnum.OPPORTUNITY_VIEW.getI18nMemo()),

    CUSTOMER_VIEW(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), "customerView", ProPermissionAliasEnum.CUSTOMER_VIEW.getI18nMemo()),

    CONTACT_VIEW(XbbRefTypeEnum.CONTACT.getCode(), "contactView", ProPermissionAliasEnum.CONTACT_VIEW.getI18nMemo()),

    CONTRACT_VIEW(XbbRefTypeEnum.CONTRACT.getCode(), "contractView", ProPermissionAliasEnum.CONTRACT_VIEW.getI18nMemo()),

    REFUND_VIEW(XbbRefTypeEnum.REFUND.getCode(), "refundView", ProPermissionAliasEnum.REFUND_VIEW.getI18nMemo()),

    WORK_REPORT_VIEW(XbbRefTypeEnum.WORK_REPORT.getCode(), "workReportView", ProPermissionAliasEnum.WORK_REPORT_VIEW.getI18nMemo()),
    WORKREPORT_DAILY_VIEW(XbbRefTypeEnum.WORKREPORT_DAILY.getCode(), "workReportView", ProPermissionAliasEnum.WORK_REPORT_VIEW.getI18nMemo()),
    WORKREPORT_WEEKLY_VIEW(XbbRefTypeEnum.WORKREPORT_WEEKLY.getCode(), "workReportView", ProPermissionAliasEnum.WORK_REPORT_VIEW.getI18nMemo()),
    WORKREPORT_MONTHLY_VIEW(XbbRefTypeEnum.WORKREPORT_MONTHLY.getCode(), "workReportView", ProPermissionAliasEnum.WORK_REPORT_VIEW.getI18nMemo()),

    PURCHASE_VIEW(XbbRefTypeEnum.PURCHASE.getCode(), "purchaseView", ProPermissionAliasEnum.PURCHASE_VIEW.getI18nMemo()),

    SUPPLIER_VIEW(XbbRefTypeEnum.SUPPLIER.getCode(), "supplierView", ProPermissionAliasEnum.SUPPLIER_VIEW.getI18nMemo()),

    INSTOCK_VIEW(XbbRefTypeEnum.INSTOCK.getCode(), "instockView", ProPermissionAliasEnum.INSTOCK_VIEW.getI18nMemo()),

    OUTSTOCK_VIEW(XbbRefTypeEnum.OUTSTOCK.getCode(), "outstockView", ProPermissionAliasEnum.OUTSTOCK_VIEW.getI18nMemo()),

    INVENTORY_VIEW(XbbRefTypeEnum.INVENTORY.getCode(), "inventoryView", ProPermissionAliasEnum.INVENTORY_VIEW.getI18nMemo()),

    TRANSFER_VIEW(XbbRefTypeEnum.TRANSFER.getCode(), "transferView", ProPermissionAliasEnum.TRANSFER_VIEW.getI18nMemo()),

    OTHER_INSTOCK_VIEW(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), "instockView", ProPermissionAliasEnum.INSTOCK_VIEW.getI18nMemo()),

    OTHER_OUTSTOCK_VIEW(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), "outstockView", ProPermissionAliasEnum.OUTSTOCK_VIEW.getI18nMemo()),

    PRODUCTION_MATERIEL_OUTSTOCK_VIEW(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.PRODUCTION_MATERIEL_OUTSTOCK_VIEW.getI18nMemo()),

    WORK_ORDER_OUTSTOCK_VIEW(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.WORK_ORDER_OUTSTOCK_VIEW.getI18nMemo()),

    RETURNED_PURCHASE_OUTSTOCK_VIEW(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.RETURNED_PURCHASE_OUTSTOCK_VIEW.getI18nMemo()),

    PURCHASE_INSTOCK_VIEW(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), ProPermissionAliasEnum.PURCHASE_INSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.PURCHASE_INSTOCK_VIEW.getI18nMemo()),

    REFUND_INSTOCK_VIEW(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), ProPermissionAliasEnum.REFUND_INSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.REFUND_INSTOCK_VIEW.getI18nMemo()),

    PRODUCTION_INSTOCK_VIEW(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), ProPermissionAliasEnum.PRODUCTION_INSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.PRODUCTION_INSTOCK_VIEW.getI18nMemo()),

    RETURNED_MATERIEL_INSTOCK_VIEW(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.RETURNED_MATERIEL_INSTOCK_VIEW.getI18nMemo()),

    CONTRACT_OUTSTOCK_VIEW(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK_VIEW.getAlias(), ProPermissionAliasEnum.CONTRACT_OUTSTOCK_VIEW.getI18nMemo()),

    WAREHOUSE_VIEW(XbbRefTypeEnum.WAREHOUSE.getCode(), "warehouseView", ProPermissionAliasEnum.WAREHOUSE_VIEW.getI18nMemo()),

    RETURN_PURCHASE_VIEW(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), "returnPurchaseView", ProPermissionAliasEnum.RETURN_PURCHASE_VIEW.getI18nMemo()),

    ASSEMBLE_VIEW(XbbRefTypeEnum.ASSEMBLE.getCode(), "assembleView", ProPermissionAliasEnum.ASSEMBLE_VIEW.getI18nMemo()),

    INVOICE_VIEW(XbbRefTypeEnum.INVOICE.getCode(), "invoiceView", ProPermissionAliasEnum.INVOICE_VIEW.getI18nMemo()),

    PURCHASE_INVOICE_VIEW(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(),"purchaseInvoiceView",ProPermissionAliasEnum.PURCHASE_INVOICE_VIEW.getI18nMemo()),

    WORK_ORDER_VIEW(XbbRefTypeEnum.WORK_ORDER.getCode(),"workOrderView", ProPermissionAliasEnum.WORK_ORDER_VIEW.getI18nMemo()),

    BOM_BILL_VIEW(XbbRefTypeEnum.BOM_BILL.getCode(), "bomBillView", ProPermissionAliasEnum.BOM_BILL_VIEW.getI18nMemo()),

    PRODUCTION_ORDER_VIEW(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), "productionOrderView", ProPermissionAliasEnum.PRODUCTION_ORDER_VIEW.getI18nMemo()),

    COMMUNICATE_PLAN_VIEW(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), "communicatePlanView", ProPermissionAliasEnum.COMMUNICATE_PLAN_VIEW.getI18nMemo()),

    PRODUCT_VIEW(XbbRefTypeEnum.PRODUCT.getCode(), "productView", ProPermissionAliasEnum.PRODUCT_VIEW.getI18nMemo()),

    PAY_PLAN_VIEW(XbbRefTypeEnum.PAY_PLAN.getCode(), "payPlanView", ProPermissionAliasEnum.PAY_PLAN_VIEW.getI18nMemo()),

    PAYMENT_VIEW(XbbRefTypeEnum.PAYMENT.getCode(), "paymentView", ProPermissionAliasEnum.PAYMENT_VIEW.getI18nMemo()),

    SUPPLIER_CONTACT_VIEW(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), "supplierContactView", ProPermissionAliasEnum.SUPPLIER_CONTACT_VIEW.getI18nMemo()),

    SUPPLIER_COMMUNICATE_VIEW(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), "supplierCommunicateView", ProPermissionAliasEnum.SUPPLIER_COMMUNICATE_VIEW.getI18nMemo()),

    QUOTATION_VIEW(XbbRefTypeEnum.QUOTATION.getCode(), ProPermissionAliasEnum.QUOTATION_VIEW.getAlias(), ProPermissionAliasEnum.QUOTATION_VIEW.getI18nMemo()),

    PAYMENT_SHEET_VIEW(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "paymentSheetView", ProPermissionAliasEnum.PAYMENT_SHEET_VIEW.getI18nMemo()),

    PAY_SHEET_VIEW(XbbRefTypeEnum.PAY_SHEET.getCode(), "paySheetView", ProPermissionAliasEnum.PAY_SHEET_VIEW.getI18nMemo()),

    SEQ_SEARCH_VIEW(XbbRefTypeEnum.SEQ_SEARCH.getCode(),  ProPermissionAliasEnum.SEQ_SEARCH_VIEW.getAlias(), ProPermissionAliasEnum.SEQ_SEARCH_VIEW.getI18nMemo()),

    BATCH_FLOW_BILL_VIEW(XbbRefTypeEnum.BATCH_FLOW_BILL.getCode(),  ProPermissionAliasEnum.BATCH_FLOW_BILL_VIEW.getAlias(), ProPermissionAliasEnum.BATCH_FLOW_BILL_VIEW.getI18nMemo()),

    CLUE_VIEW(XbbRefTypeEnum.CLUE.getCode(), ProPermissionAliasEnum.CLUE_VIEW.getAlias(), ProPermissionAliasEnum.CLUE_VIEW.getI18nMemo()),

    MARKET_ACTIVITY_VIEW(XbbRefTypeEnum.MARKET_ACTIVITY.getCode(), ProPermissionAliasEnum.MARKET_ACTIVITY_VIEW.getAlias(), ProPermissionAliasEnum.MARKET_ACTIVITY_VIEW.getI18nMemo()),

    VIEW_STATEMENT(XbbRefTypeEnum.CUSTOMER_STATEMENT_STATISTIC.getCode(), ProPermissionAliasEnum.VIEW_STATEMENT.getAlias(), ProPermissionAliasEnum.VIEW_STATEMENT.getI18nMemo()),

    CREDIT_LIMIT_VIEW(XbbRefTypeEnum.CREDIT_LIMIT.getCode(), ProPermissionAliasEnum.CREDIT_LIMIT_VIEW.getAlias(), ProPermissionAliasEnum.CREDIT_LIMIT_VIEW.getI18nMemo()),
    CREDIT_TEMPORARY_LIMIT_VIEW(XbbRefTypeEnum.CREDIT_TEMPORARY_LIMIT.getCode(), ProPermissionAliasEnum.CREDIT_TEMPORARY_LIMIT_VIEW.getAlias(), ProPermissionAliasEnum.CREDIT_TEMPORARY_LIMIT_VIEW.getI18nMemo()),
    CREDIT_FIXED_LIMIT_VIEW(XbbRefTypeEnum.CREDIT_FIXED_LIMIT.getCode(), ProPermissionAliasEnum.CREDIT_FIXED_LIMIT_VIEW.getAlias(), ProPermissionAliasEnum.CREDIT_FIXED_LIMIT_VIEW.getI18nMemo()),
    CREDIT_CARD_BILL_VIEW(XbbRefTypeEnum.CREDIT_CARD_BILL.getCode(), ProPermissionAliasEnum.CREDIT_CARD_BILL_VIEW.getAlias(), ProPermissionAliasEnum.CREDIT_CARD_BILL_VIEW.getI18nMemo()),

    DISTRIBUTOR_COMMUNICATE_VIEW(XbbRefTypeEnum.DISTRIBUTOR_COMMUNICATE.getCode(), "distributorCommunicateView", ProPermissionAliasEnum.CUSTOMER_COMMUNICATE_VIEW.getI18nMemo()),

    DISTRIBUTOR_VIEW(XbbRefTypeEnum.DISTRIBUTOR_MANAGEMENT.getCode(), "distributorView", ProPermissionAliasEnum.DISTRIBUTOR_VIEW.getI18nMemo()),

    DISTRIBUTOR_CONTACT_VIEW(XbbRefTypeEnum.DISTRIBUTOR_CONTACT.getCode(), "distributorContactView", ProPermissionAliasEnum.DISTRIBUTOR_CONTACT_VIEW.getI18nMemo()),

    MARKETING_ACTIVITY_VIEW(XbbRefTypeEnum.MARKETING_ACTIVITY_MANAGEMENT.getCode(), "marketingActivityView", ProPermissionAliasEnum.MARKETING_ACTIVITY_VIEW.getI18nMemo()),

    PROMOTION_ACTIVITY_VIEW(XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getCode(), "promotionActivityView", ProPermissionAliasEnum.PROMOTION_ACTIVITY_VIEW.getI18nMemo()),

    ORDEER_VIEW(XbbRefTypeEnum.ORDER.getCode(),"orderView", ProPermissionAliasEnum.ORDER_VIEW.getI18nMemo()),


    OTHER_INCOME_VIEW(XbbRefTypeEnum.OTHER_INCOME.getCode(), ProPermissionAliasEnum.OTHER_INCOME_VIEW.getAlias(), ProPermissionAliasEnum.OTHER_INCOME_VIEW.getI18nMemo()),

    OTHER_EXPENSE_VIEW(XbbRefTypeEnum.OTHER_EXPENSE.getCode(), ProPermissionAliasEnum.OTHER_EXPENSE_VIEW.getAlias(), ProPermissionAliasEnum.OTHER_EXPENSE_VIEW.getI18nMemo()),

    FUND_TRANSFER_VIEW(XbbRefTypeEnum.FUND_TRANSFER.getCode(), ProPermissionAliasEnum.FUND_TRANSFER_VIEW.getAlias(), ProPermissionAliasEnum.FUND_TRANSFER_VIEW.getI18nMemo()),

    COST_ADJUST_VIEW(XbbRefTypeEnum.COST_ADJUST.getCode(), ProPermissionAliasEnum.COST_ADJUST_VIEW.getAlias(), ProPermissionAliasEnum.COST_ADJUST_VIEW.getI18nMemo()),

    COMPETITOR_VIEW(XbbRefTypeEnum.COMPETITOR.getCode(),ProPermissionAliasEnum.COMPETITOR_VIEW.getAlias(),ProPermissionAliasEnum.COMPETITOR_VIEW.getI18nMemo()),
    /**
     * 工单v2
     */
    WORK_ORDER_V2_VIEW(XbbRefTypeEnum.WORK_ORDER_V2.getCode(),ProPermissionAliasEnum.WORK_ORDER_V2_VIEW.getAlias(),ProPermissionAliasEnum.WORK_ORDER_V2_VIEW.getI18nMemo()),
    RECEIPT_ORDER_VIEW(XbbRefTypeEnum.RECEIPT_ORDER.getCode(),ProPermissionAliasEnum.RECEIPT_ORDER_VIEW.getAlias(),ProPermissionAliasEnum.RECEIPT_ORDER_VIEW.getI18nMemo()),
    SERVICE_PROJECT_VIEW(XbbRefTypeEnum.SERVICE_PROJECT.getCode(),ProPermissionAliasEnum.SERVICE_PROJECT_VIEW.getAlias(),ProPermissionAliasEnum.SERVICE_PROJECT_VIEW.getI18nMemo()),
    SLA_LOG_VIEW(XbbRefTypeEnum.SLA_LOG.getCode(),ProPermissionAliasEnum.SLA_LOG_VIEW.getAlias(),ProPermissionAliasEnum.SLA_LOG_VIEW.getI18nMemo()),

    ;
    private Integer code;

    private String alias;

    private String memo;

    ViewProPermissionAliasEnum(Integer code, String alias, String memo) {
        this.code = code;
        this.alias = alias;
        this.memo = memo;
    }

    public static ViewProPermissionAliasEnum getByCode(Integer businessType) {
        for (ViewProPermissionAliasEnum item: values()) {
            if (Objects.equals(item.getCode(), businessType)) {
                return item;
            }
        }
        if (XbbRefTypeEnum.checkPaymentSheet(businessType)) {
            //如果是回款单类型，则返回回款单查看权限
            return PAYMENT_SHEET_VIEW;
        }else if (XbbRefTypeEnum.checkPaySheet(businessType)) {
            //如果是付款单类型，则返回付款单查看权限
            return PAY_SHEET_VIEW;
        }  else if (XbbRefTypeEnum.checkOtherIncome(businessType)) {
            return OTHER_INCOME_VIEW;
        }  else if (XbbRefTypeEnum.checkOtherExpense(businessType)) {
            return OTHER_EXPENSE_VIEW;
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
